/*
 * Quad4.h
 *
 *  Created on: 16.01.2014
 *      Author: Stefan
 */

#ifndef QUAD4_H_
#define QUAD4_H_

#include <math.h>
#include "Property.h"
#include "Node.h"

class Quad4 {
private:
	//Variables
	int iType; //0=Axissymmetric, 1=Plane Strain, 2=Plane Stress
	int iIntegrationOrder;
	double dJacobian; //Jacobian at current integration point

	double dThickness;
	double aNodes[2][4];
	double aStressStrainMatrix[3][3];
	double aStrainDisplacementMatrix[3][8];
	/// TODO: Fix this to static const!
	double aGaussPointPosition[3][4] = { { 0, 0, 0, 0 }, { -sqrt(1. / 3.), sqrt(1. / 3.), 0, 0 }, { -sqrt(3. / 5.), 0, sqrt(3. / 5.), 0 } };
	double aGaussWeightingFactors[3][4] = { { 2., 0, 0, 0 }, { 1., 1., 0, 0 }, { 5. / 9., 8. / 9., 5. / 9., 0 } };
//
	Property *pProperty;


	void createStressStrainMatrix();
	void calculateStrainDisplacementMatrix(double dR, double dS);
	void createStiffnessMatrix();
	void calculateStrains();
	void calculateStresses();
	void getDisplacements();

public:
	int iId;
	int iNumberOfDofs = 8;
	Node *nNodes[4];
	//int aNodeNumbers[4];
	double aStiffnessMartix[8][8];
	float aStrains[3];
	float aStresses[3];
	double aDisplacements[8];

	void calculateResults();

	Quad4(int iId, Property *pProperty, Node *nN1, Node *nN2, Node *nN3, Node *nN4);
};

#endif /* QUAD4_H_ */
